import { getSearchList } from "@/api";

const state = {
  //搜索的数据
  searchList: {},
};

const mutations = {
  //设置搜索的数据
  getSearchList(state, data) {
    state.searchList = data;
  },
};
const actions = {
  //获取搜索的数据
  async getSearchList({ commit }, params) {
    const res = await getSearchList(params);
    if (res.code === 200) {
      commit("getSearchList", res.data);
    }
  },
};
const getters = {
  //过滤数据,state为当前仓库的
  goodsList(state) {
    return state.searchList.goodsList || [];
  },
  trademarkList(state) {
    return state.searchList.trademarkList || [];
  },
  attrsList(state) {
    return state.searchList.attrsList || [];
  },
};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
